﻿namespace TableTool
{
    public partial class 伤害计算 : Form
    {
        /// <summary>
        /// 伤害时间
        /// </summary>
        TimeSpan time { get; set; }
        public 伤害计算()
        {
            InitializeComponent();
            time = new TimeSpan();
        }
        /// <summary>
        /// +1s
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd1s_Click(object sender, EventArgs e)
        {
            time += TimeSpan.FromSeconds(1);
            tbTime.Text = time.TotalSeconds.ToString();
            SubShanghai(1);
        }
        /// <summary>
        /// +1m
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd1m_Click(object sender, EventArgs e)
        {
            time += TimeSpan.FromMinutes(1);
            tbTime.Text = time.TotalSeconds.ToString();
            SubShanghai(60);
        }
        /// <summary>
        ///  归零
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClear_Click(object sender, EventArgs e)
        {
            time = TimeSpan.FromSeconds(0);
            tbTime.Text = time.TotalSeconds.ToString();
            double.TryParse(tbBossHp.Text, out bossNowHp);
        }
        /// <summary>
        /// 
        /// </summary>
        double bossNowHp;
        /// <summary>
        /// 伤害
        /// </summary>
        /// <param name="count"></param>
        private void SubShanghai(int count)
        {
            double.TryParse(tbBossHp.Text, out double bossAllHp);
            for (int i = 0; i < count; i++)
            {
                double.TryParse(tbGongji.Text, out double gongji);
                double shanghai = gongji;
                if (bossAllHp / 2 > bossNowHp)
                {
                    //hp50以下
                    double.TryParse(tbgjhpdown50.Text, out double gongjihp50down);
                    shanghai += gongji * (gongjihp50down / 100);
                }
                else
                {
                    //hp50以上
                    double.TryParse(tbgjhpup50.Text, out double gongjihp50up);
                    shanghai += gongji * (gongjihp50up / 100);
                }
                bossNowHp -= shanghai;

            }
            label4.Text = "当前血量:" + bossNowHp;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            double jichugongji = 8000;
            double zengfubili = 1;

            string message = "";
            for (double i = 50; i < 70; i++)
            {
                var zengfu = jichugongji * (i / 100);
                var value = jichugongji + zengfu;
                message += "基础攻击" + jichugongji + " 增幅比例" + zengfu + " 结果:" + value + "\r\n";
            }
            label7.Text = message;
            message = "";
            for (double i = 10; i < 100; i += 10)
            {
                double bi = 50;
                double bili = 100;
                var zengfu = (jichugongji + i) * (bi / bili);
                var value = jichugongji + i + zengfu;
                message += "基础攻击" + (jichugongji + i) + " 增幅比例" + zengfu + " 结果:" + value + "\r\n";
            }
            label8.Text = message;
        }

        private void 伤害计算_Load(object sender, EventArgs e)
        {

        }
    }
}
